package com.homework.oop;

public class Vehicle {
    private int speed;
    private int size;

    public Vehicle(int speed, int size) {
        this.speed = speed;
        this.size = size;
    }

    @Override
    public String toString() {
        return "Vehicle{" +
                "speed=" + speed +
                ", size=" + size +
                '}';
    }

    public void setSpeed(int speed){
        this.speed = speed;
    }

    public void speedUp(int speed){
        this.speed += speed;
        System.out.println("已加速，当前速度为：" + this.speed);
    }

    public void speedDown(int speed){
        this.speed -= speed;
        System.out.println("已减速，当前速度为：" + this.speed);
    }

  public static void main(String[] args) {
    //
      Vehicle v = new Vehicle(100,20);
      v.toString();
      v.speedUp(100);
      v.speedDown(50);
      v.setSpeed(300);
  }
}
